﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

public class LaneDefinition
{
    public string Name { get; private set; }
    public string WipLimit { get; private set; }
    public string WipFloor { get; private set; }

    private List<LaneState> _states = new List<LaneState>();

    public LaneDefinition(XmlNode laneDefinition)
    {
        Name = laneDefinition.Attributes["Name"].Value;
        WipLimit = GetProperty("WipLimit", laneDefinition);
        WipFloor = GetProperty("WipFloor", laneDefinition);

        foreach (XmlNode state in laneDefinition.SelectNodes("TfsState"))
        {
            _states.Add(new LaneState(state));
        }
    }

    public IEnumerable<LaneState> LaneStates
    {
        get { return _states; }
    }

    private string GetProperty(string attributeName, XmlNode node)
    {
        XmlAttribute attributeValue = node.Attributes[attributeName];
        return (attributeValue == null) ? String.Empty : attributeValue.Value;
    }
}